package fr.inserm.umr915.vcfannotator.annotators;

import java.util.regex.Pattern;

import fr.inserm.umr915.libjson.ObjectNode;




public class ThirdPartyVcfAnnotator extends PositionalDelimiterAnnotator
	{
	private String vcfName;
	public ThirdPartyVcfAnnotator()
		{
		setChromColumn(0);
		setChromStartColumn(1);
		setChromEndColumn(1);
		setPattern(Pattern.compile("[\t]"));
		setSplitLimit(7);
		setPositionsZeroBased(false);
		}
	
	public String getVcfName()
		{
		return vcfName;
		}
	
	public void setVcfName(String vcfName)
		{
		this.vcfName = vcfName;
		}
	
	@Override
	public boolean ignore(String line)
		{
		return line.startsWith("#");
		}
	@Override
	public ObjectNode createAnnotation(String[] tokens)
		{
		ObjectNode annotation = super.nodeFactory.createObjectNode();
		annotation.put("vcf", getVcfName());
		annotation.put("alt", tokens[4]);
		if(!(tokens[2].equals(".") || tokens[2].isEmpty()))
			{
			annotation.put("id", tokens[2]);
			}
		return annotation;
		}
	}
